home *** CD-ROM | disk | FTP | other *** search
/ Ian & Stuart's Australian Mac 1 / Ian and Stuart's One (Australia).iso / Australasian Legends / Commercial / Rainbow Hill / MacDOS™ 2.0.0 / batches / testINCR.bat < prev    next >
DOS Batch File  |  1993-05-28  |  6KB  |  232 lines

  1. !  testINCR.bat    Batch file to test the command INCR
  2. @echo off
  3. !
  4. !  In these comments, the espression "contains an integer" when referring to a variable value
  5. !  or a command argument actually means "is a string entirely consisting of the ASCII characters
  6. !  '0' to '9' and possibly preceded by a leading sign".
  7. !
  8. !  The format of INCR is:   INCR [sign]var [BY what]
  9. !
  10. !      When <sign> is omitted, it is assumed to be '+'.
  11. !      When <BY what> is omitted, <what> is set to be an integer of value "1".
  12. !
  13. !  The following possibilities need to be tested:
  14. !
  15. !      Both <var> and <what> contain an integer (eg. "+42" and "-18" respectively) 
  16. !  1       <var> is set to %var% + what (eg. "24")
  17. !
  18. !      <var> contains a non-integer (eg. "MacDOS is OK")
  19. !          <what> contains a positive integer (eg. "1")
  20. !              <sign> is a '+'
  21. !  2               <what> spaces are appended to <var> (eg. "MacDOS is OK ").
  22. !              <sign> is a '-'
  23. !  3               <what> spaces are prepended to <var> (eg. " MacDOS is OK").
  24. !          <what> contains a negative integer (eg. "-3")
  25. !              <sign> is a '+'
  26. !  4               <what> characters are removed from the end of <var> (eg. "MacDOS is").
  27. !              <sign> is a '-'
  28. !  5               <what> characters are removed from the beginning of <var> (eg. "DOS is OK").
  29. !          <what> contains a non-integer (eg. "?!?")
  30. !              <sign> is a '+'
  31. !  6               <what> is appended to <var> (eg. "MacDOS is OK?!?").
  32. !             <sign> is a '-'
  33. !  7               <what> is prepended to <var> (eg. "?!?MacDOS is OK").
  34. !
  35. !  Note: a basic test was done before executing this batch file.
  36. !
  37. !  Copyright © 1993 by Rainbow Hill Pty Ltd. All rights reserved.
  38. !
  39.  
  40.     set test =1
  41.  
  42. !--------------------------------------here the tests begin-----------------------------------------
  43. :LBL_1
  44.     !                        +numeric default
  45.     set var  =+5
  46.     set cntl =6
  47.     set remark =incr "%var%"
  48.     incr var
  49.     goto REPORT_LBL
  50.  
  51. :LBL_2
  52.     !                        numeric default
  53.     set var  =0
  54.     set cntl =1
  55.     set remark =incr "%var%"
  56.     incr var
  57.     goto REPORT_LBL
  58.  
  59. :LBL_3
  60.     !                        -numeric default
  61.     set var  =-4
  62.     set cntl =-3
  63.     set remark =incr "%var%"
  64.     incr var
  65.     goto REPORT_LBL
  66.  
  67. :LBL_4
  68.     !                        sign -numeric default
  69.     set var  =-1
  70.     set cntl =0
  71.     set remark =incr -"%var%"
  72.     incr -var
  73.     goto REPORT_LBL
  74.  
  75. :LBL_5
  76.     !                        +numeric +numeric
  77.     set var  =33
  78.     set what =11
  79.     set cntl =44
  80.     goto STD_TEST_LBL
  81.  
  82. :LBL_6
  83.     !                        +numeric -numeric
  84.     set var  =11
  85.     set what =-33
  86.     set cntl =-22
  87.     goto STD_TEST_LBL
  88.  
  89. :LBL_7
  90.     !                        +numeric alpha
  91.     set var  =1234567
  92.     set what =87654321a
  93.     set cntl =123456787654321a
  94.     goto STD_TEST_LBL
  95.  
  96. :LBL_8
  97.     !                        alpha alpha
  98.     set var  =this
  99.     set what = is right
  100.     set cntl =this is right
  101.     goto STD_TEST_LBL
  102.  
  103. :LBL_9
  104.     !                        sign alpha alpha
  105.     set var  = front
  106.     set what =back to
  107.     set cntl =back to front
  108.     set remark =incr -"%var%" by "%what%"
  109.     incr -var by %what%
  110.     goto REPORT_LBL
  111.  
  112. :LBL_10
  113.     !                        alpha +numeric
  114.     set var  =three spaces:
  115.     set what =3
  116.     set cntl =three spaces:   
  117.     goto STD_TEST_LBL
  118.  
  119. :LBL_11
  120.     !                        alpha -numeric
  121.     set var  =clean !vsd67504fv0-v
  122.     set what =-13
  123.     set cntl =clean !
  124.     goto STD_TEST_LBL
  125.  
  126. :LBL_12
  127.     !                        alpha -numeric
  128.     set var  =nothing left
  129.     set what =-12
  130.     ! When 'var' is set to nothing, it is removed from the variable list. When we try to
  131.     ! check it later on, it is not replaced because it does not exist. <cntl> is set to
  132.     ! "%VAR%" so that the check succeeds, confirming that 'var' was removed.
  133.     set cntl =%%VAR%%
  134.     goto STD_TEST_LBL
  135.  
  136. :LBL_13
  137.     !                        alpha -numeric
  138.     set var  =less than nothing left !
  139.     set what =-100000
  140.     set cntl =%%VAR%%
  141.     goto STD_TEST_LBL
  142.  
  143. :LBL_14
  144.     !                        alpha +numeric
  145.     set var  =maximum length line (currently 127 characters)
  146.     set what =+100000
  147.     set remark =incr "%var%" by "%what%"
  148.     incr var by %what%
  149.     ! we have to cut some of the spaces before making the comparison, because the command line
  150.     ! itself cannot be longer than 127 and the 'IF' would not be executable. Let's chop 126
  151.     ! characters, so that we are just left with a single 'm'.
  152.     incr var by -126
  153.     set cntl =m
  154.     goto REPORT_LBL
  155.  
  156. :LBL_15
  157.     !                        sign alpha +numeric
  158.     set var  =: three spaces
  159.     set what =3
  160.     set cntl =   : three spaces
  161.     set remark =incr -"%var%" by "%what%"
  162.     incr -var by %what%
  163.     goto REPORT_LBL
  164.  
  165. :LBL_16
  166.     !                        sign alpha -numeric
  167.     set var  =vsd67504fv0-vclean !
  168.     set what =-13
  169.     set cntl =clean !
  170.     set remark =incr -"%var%" by "%what%"
  171.     incr -var by %what%
  172.     goto REPORT_LBL
  173.  
  174. :LBL_17
  175.     !                        sign alpha -numeric
  176.     set var  =nothing left
  177.     set what =-12
  178.     ! When 'var' is set to nothing, it is removed from the variable list. When we try to
  179.     ! check it later on, it is not replaced because it does not exist. <cntl> is set to
  180.     ! "%VAR%" so that the check succeeds, confirming that 'var' was removed.
  181.     set cntl =%%VAR%%
  182.     set remark =incr -"%var%" by "%what%"
  183.     incr -var by %what%
  184.     goto REPORT_LBL
  185.  
  186. :LBL_18
  187.     !                        sign alpha -numeric
  188.     set var  =less than nothing left !
  189.     set what =-100000
  190.     set cntl =%%VAR%%
  191.     set remark =incr -"%var%" by "%what%"
  192.     incr -var by %what%
  193.     goto REPORT_LBL
  194.  
  195. :LBL_19
  196.     !                        sign alpha +numeric
  197.     set var  =maximum length line (currently 127 characters)
  198.     set what =+100000
  199.     set remark =incr -"%var%" by "%what%"
  200.     incr -var by %what%
  201.     ! we have to cut some of the spaces before making the comparison, because the command line
  202.     ! itself cannot be longer than 127 and the 'IF' would not be executable. Let's chop 126
  203.     ! characters from the beginning, so that we are just left with a single ')'.
  204.     incr -var by -126
  205.     set cntl =)
  206.     goto REPORT_LBL
  207.  
  208. !--------------------------------------standard test-----------------------------------------------
  209. :STD_TEST_LBL
  210.     set remark =incr "%var%" by "%what%"
  211.     incr var by %what%
  212.     !                        then it falls through to the report...
  213.  
  214. !-----------------------------routine to report the result of a test--------------------------------
  215. :REPORT_LBL
  216.     if %var%==%cntl% goto SUCCESS_LBL
  217.     echo Test %test% (%remark% = "%var%") failed: the result should have been "%cntl%"
  218.     goto CONTINUE_LBL
  219. :SUCCESS_LBL
  220. echo off
  221.     echo Test %test% (%remark% = "%var%") successful
  222. :CONTINUE_LBL
  223.     incr test
  224.     goto LBL_%test%
  225.     !                        when the last test is done, it will just fall through...
  226.  
  227. !---------------------------------- That's it folks ! ----------------------------------------------
  228.     set remark=
  229.     set var=
  230.     set what=
  231.     set cntl=
  232.     set test=